from flask import Flask
from flask import request
from flask import render_template
from reserch import reserch4letters

app = Flask(__name__)

# 首页

@app.route('/',methods=['GET','POST'])
def index_world():
    return render_template('index.html')

# 名字全称拼写

@app.route('/name',methods=['GET'])
def name():
    return render_template('hello.html')

@app.route('/submit_name',methods=['POST'])
def submit_name():
    firstName = request.form['firstName']
    lastName = request.form['lastName']
    fullName = lastName + firstName
    return render_template('hello.html', first_name=firstName,last_name=lastName,
    full_name=fullName)

# 元音字频统计

@app.route('/word',methods=['GET'])
def word():
    return render_template('word.html')

@app.route('/submit_word',methods=['POST'])
def submit_word():
    word = request.form['word']
    vowels = request.form['vowels']
    found = reserch4letters(vowels,word)
    num = 0
    for i in found:
        num = found[i]
    return render_template('word.html', num=num,word=word,vowels=vowels)

if __name__ == '__main__':
    app.run(host='127.0.0.1',port=5000,debug=True)